package com.example.automanagement.mapper;

import com.example.automanagement.entity.*;
import com.example.automanagement.views.DepartmentRole;
import org.apache.ibatis.annotations.*;


@Mapper
public interface ApplicationMapper {
    void  addAutoOrder(@Param("autoOrder") AutoOrder autoOrder);

    void addRepairOrder(@Param("repairOrder")RepairOrder repairOrder);
    GeneralRole getUserIdByGn();

    DepartmentRole getUserIdByDR(String userRole, String userDepartment);
    @Insert("insert into todo(user_id, todo_time, todo_type, order_id, todo_status) " +
            "values (#{userId}, #{todoTime}, #{todoType}, #{orderId}, #{todoStatus})")
    void addTodo(ToDo toDo);
    @Update("update auto_order set auto_order_progress = #{autoOrderProgress} where auto_order.auto_order_id = #{orderId} ")
    void updateAutoOrderStatus(String orderId, String autoOrderProgress);
    @Select("select auto_order_id from auto_order where submit_time = #{submitTime}")
    AutoOrder getAutoOrderIdByTime(String submitTime);
    @Select("select repair_order_id from repair_order where submit_time = #{submitTime}")
    RepairOrder getRepairOrderIdByTime(String submitTime);
    @Update("update todo set todo_status = '已完成' where todo_type = #{todoType} and order_id = #{orderId}")
    void updateTodoDone(String todoType, String orderId);
    @Update("update repair_order set repair_order_progress = #{repairOrderProgress} where repair_order_id = #{orderId} " )
    void updateRepairOrderStatus(String orderId, String repairOrderProgress);
}
